diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index ecf64392a9a..57bd9860d12 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -546,7 +546,7 @@ namespace ts { function getLanguageVariant(fileName: string) { // .tsx and .jsx files are treated as jsx language variant. - return fileExtensionIs(fileName, ".tsx") || fileExtensionIs(fileName, ".jsx") ? LanguageVariant.JSX : LanguageVariant.Standard; + return fileExtensionIs(fileName, ".tsx") || fileExtensionIs(fileName, ".jsx") || fileExtensionIs(fileName, ".js") ? LanguageVariant.JSX : LanguageVariant.Standard; } function initializeState(fileName: string, _sourceText: string, languageVersion: ScriptTarget, isJavaScriptFile: boolean, _syntaxCursor: IncrementalParser.SyntaxCursor) { diff --git a/tests/baselines/reference/jsFileCompilationTypeAssertions.errors.txt b/tests/baselines/reference/jsFileCompilationTypeAssertions.errors.txt index e73ee46fb89..662eea4d405 100644 --- a/tests/baselines/reference/jsFileCompilationTypeAssertions.errors.txt +++ b/tests/baselines/reference/jsFileCompilationTypeAssertions.errors.txt @@ -1,9 +1,12 @@ error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. -tests/cases/compiler/a.js(1,10): error TS8016: 'type assertion expressions' can only be used in a .ts file. +tests/cases/compiler/a.js(1,10): error TS17008: JSX element 'string' has no corresponding closing tag. +tests/cases/compiler/a.js(1,27): error TS1005: 'undefined; ~~~~~~ -!!! error TS8016: 'type assertion expressions' can only be used in a .ts file. \ No newline at end of file +!!! error TS17008: JSX element 'string' has no corresponding closing tag. + +!!! error TS1005: ' - -// @allowJs: true -// @Filename: a.js -//// var v = undefined; - -verify.getSyntacticDiagnostics(`[]`); -verify.getSemanticDiagnostics(`[ - { - "message": "'type assertion expressions' can only be used in a .ts file.", - "start": 9, - "length": 6, - "category": "error", - "code": 8016 - } -]`); \ No newline at end of file