@@ -1797,7 +1797,7 @@ namespace ts {
1797
1797
case SyntaxKind . PropertyDeclaration :
1798
1798
case SyntaxKind . MethodDeclaration :
1799
1799
if ( ( < ParameterDeclaration | PropertyDeclaration | MethodDeclaration > parent ) . questionToken === node ) {
1800
- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . _0_can_only_be_used_in_a_ts_file , "?" ) ) ;
1800
+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . The_0_modifier_can_only_be_used_in_TypeScript_files , "?" ) ) ;
1801
1801
return ;
1802
1802
}
1803
1803
// falls through
@@ -1811,45 +1811,48 @@ namespace ts {
1811
1811
case SyntaxKind . VariableDeclaration :
1812
1812
// type annotation
1813
1813
if ( ( < FunctionLikeDeclaration | VariableDeclaration | ParameterDeclaration | PropertyDeclaration > parent ) . type === node ) {
1814
- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . types_can_only_be_used_in_a_ts_file ) ) ;
1814
+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . Type_annotations_can_only_be_used_in_TypeScript_files ) ) ;
1815
1815
return ;
1816
1816
}
1817
1817
}
1818
1818
1819
1819
switch ( node . kind ) {
1820
1820
case SyntaxKind . ImportEqualsDeclaration :
1821
- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . import_can_only_be_used_in_a_ts_file ) ) ;
1821
+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . import_can_only_be_used_in_TypeScript_files ) ) ;
1822
1822
return ;
1823
1823
case SyntaxKind . ExportAssignment :
1824
1824
if ( ( < ExportAssignment > node ) . isExportEquals ) {
1825
- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . export_can_only_be_used_in_a_ts_file ) ) ;
1825
+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . export_can_only_be_used_in_TypeScript_files ) ) ;
1826
1826
return ;
1827
1827
}
1828
1828
break ;
1829
1829
case SyntaxKind . HeritageClause :
1830
1830
const heritageClause = < HeritageClause > node ;
1831
1831
if ( heritageClause . token === SyntaxKind . ImplementsKeyword ) {
1832
- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . implements_clauses_can_only_be_used_in_a_ts_file ) ) ;
1832
+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . implements_clauses_can_only_be_used_in_TypeScript_files ) ) ;
1833
1833
return ;
1834
1834
}
1835
1835
break ;
1836
1836
case SyntaxKind . InterfaceDeclaration :
1837
- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . interface_declarations_can_only_be_used_in_a_ts_file ) ) ;
1837
+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . Interface_declaration_cannot_have_implements_clause ) ) ;
1838
1838
return ;
1839
1839
case SyntaxKind . ModuleDeclaration :
1840
- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . module_declarations_can_only_be_used_in_a_ts_file ) ) ;
1840
+ const moduleKeyword = node . flags & NodeFlags . Namespace ? tokenToString ( SyntaxKind . NamespaceKeyword ) : tokenToString ( SyntaxKind . ModuleKeyword ) ;
1841
+ Debug . assertDefined ( moduleKeyword ) ;
1842
+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . _0_declarations_can_only_be_used_in_TypeScript_files , moduleKeyword ) ) ;
1841
1843
return ;
1842
1844
case SyntaxKind . TypeAliasDeclaration :
1843
- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . type_aliases_can_only_be_used_in_a_ts_file ) ) ;
1845
+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . Type_aliases_can_only_be_used_in_TypeScript_files ) ) ;
1844
1846
return ;
1845
1847
case SyntaxKind . EnumDeclaration :
1846
- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . enum_declarations_can_only_be_used_in_a_ts_file ) ) ;
1848
+ const enumKeyword = Debug . assertDefined ( tokenToString ( SyntaxKind . EnumKeyword ) ) ;
1849
+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . _0_declarations_can_only_be_used_in_TypeScript_files , enumKeyword ) ) ;
1847
1850
return ;
1848
1851
case SyntaxKind . NonNullExpression :
1849
- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . non_null_assertions_can_only_be_used_in_a_ts_file ) ) ;
1852
+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . Non_null_assertions_can_only_be_used_in_TypeScript_files ) ) ;
1850
1853
return ;
1851
1854
case SyntaxKind . AsExpression :
1852
- diagnostics . push ( createDiagnosticForNode ( ( node as AsExpression ) . type , Diagnostics . type_assertion_expressions_can_only_be_used_in_a_ts_file ) ) ;
1855
+ diagnostics . push ( createDiagnosticForNode ( ( node as AsExpression ) . type , Diagnostics . Type_assertion_expressions_can_only_be_used_in_TypeScript_files ) ) ;
1853
1856
return ;
1854
1857
case SyntaxKind . TypeAssertionExpression :
1855
1858
Debug . fail ( ) ; // Won't parse these in a JS file anyway, as they are interpreted as JSX.
@@ -1878,7 +1881,7 @@ namespace ts {
1878
1881
case SyntaxKind . ArrowFunction :
1879
1882
// Check type parameters
1880
1883
if ( nodes === ( < DeclarationWithTypeParameterChildren > parent ) . typeParameters ) {
1881
- diagnostics . push ( createDiagnosticForNodeArray ( nodes , Diagnostics . type_parameter_declarations_can_only_be_used_in_a_ts_file ) ) ;
1884
+ diagnostics . push ( createDiagnosticForNodeArray ( nodes , Diagnostics . Type_parameter_declarations_can_only_be_used_in_TypeScript_files ) ) ;
1882
1885
return ;
1883
1886
}
1884
1887
// falls through
@@ -1894,7 +1897,7 @@ namespace ts {
1894
1897
if ( nodes === ( < PropertyDeclaration > parent ) . modifiers ) {
1895
1898
for ( const modifier of < NodeArray < Modifier > > nodes ) {
1896
1899
if ( modifier . kind !== SyntaxKind . StaticKeyword ) {
1897
- diagnostics . push ( createDiagnosticForNode ( modifier , Diagnostics . _0_can_only_be_used_in_a_ts_file , tokenToString ( modifier . kind ) ) ) ;
1900
+ diagnostics . push ( createDiagnosticForNode ( modifier , Diagnostics . The_0_modifier_can_only_be_used_in_TypeScript_files , tokenToString ( modifier . kind ) ) ) ;
1898
1901
}
1899
1902
}
1900
1903
return ;
@@ -1903,7 +1906,7 @@ namespace ts {
1903
1906
case SyntaxKind . Parameter :
1904
1907
// Check modifiers of parameter declaration
1905
1908
if ( nodes === ( < ParameterDeclaration > parent ) . modifiers ) {
1906
- diagnostics . push ( createDiagnosticForNodeArray ( nodes , Diagnostics . parameter_modifiers_can_only_be_used_in_a_ts_file ) ) ;
1909
+ diagnostics . push ( createDiagnosticForNodeArray ( nodes , Diagnostics . Parameter_modifiers_can_only_be_used_in_TypeScript_files ) ) ;
1907
1910
return ;
1908
1911
}
1909
1912
break ;
@@ -1915,7 +1918,7 @@ namespace ts {
1915
1918
case SyntaxKind . TaggedTemplateExpression :
1916
1919
// Check type arguments
1917
1920
if ( nodes === ( < NodeWithTypeArguments > parent ) . typeArguments ) {
1918
- diagnostics . push ( createDiagnosticForNodeArray ( nodes , Diagnostics . type_arguments_can_only_be_used_in_a_ts_file ) ) ;
1921
+ diagnostics . push ( createDiagnosticForNodeArray ( nodes , Diagnostics . Type_arguments_can_only_be_used_in_TypeScript_files ) ) ;
1919
1922
return ;
1920
1923
}
1921
1924
break ;
@@ -1941,7 +1944,7 @@ namespace ts {
1941
1944
case SyntaxKind . ReadonlyKeyword :
1942
1945
case SyntaxKind . DeclareKeyword :
1943
1946
case SyntaxKind . AbstractKeyword :
1944
- diagnostics . push ( createDiagnosticForNode ( modifier , Diagnostics . _0_can_only_be_used_in_a_ts_file , tokenToString ( modifier . kind ) ) ) ;
1947
+ diagnostics . push ( createDiagnosticForNode ( modifier , Diagnostics . The_0_modifier_can_only_be_used_in_TypeScript_files , tokenToString ( modifier . kind ) ) ) ;
1945
1948
break ;
1946
1949
1947
1950
// These are all legal modifiers.
0 commit comments