mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-06 06:49:29 -05:00
Treat the .jsx and .tsx files as jsx when parsing and .js files are parsed in standard mode
This commit is contained in:
@@ -537,7 +537,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getLanguageVariant(fileName: string) {
|
||||
return isTsx(fileName) || isJavaScript(fileName) ? LanguageVariant.JSX : LanguageVariant.Standard;
|
||||
// .tsx and .jsx files are treated as jsx language variant.
|
||||
return fileExtensionIs(fileName, ".tsx") || fileExtensionIs(fileName, ".jsx") ? LanguageVariant.JSX : LanguageVariant.Standard;
|
||||
}
|
||||
|
||||
function initializeState(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor) {
|
||||
|
||||
@@ -2142,10 +2142,6 @@ namespace ts {
|
||||
return hasExtension(fileName) && forEach(supportedJavascriptExtensions, extension => fileExtensionIs(fileName, extension));
|
||||
}
|
||||
|
||||
export function isTsx(fileName: string) {
|
||||
return fileExtensionIs(fileName, ".tsx");
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace each instance of non-ascii characters by one, two, three, or four escape sequences
|
||||
* representing the UTF-8 encoding of the character, and return the expanded char code list.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
error TS5055: Cannot write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,27): error TS17002: Expected corresponding JSX closing tag for 'string'.
|
||||
tests/cases/compiler/a.js(1,10): error TS8016: 'type assertion expressions' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
var v = <string>undefined;
|
||||
|
||||
!!! error TS17002: Expected corresponding JSX closing tag for 'string'.
|
||||
~~~~~~
|
||||
!!! error TS8016: 'type assertion expressions' can only be used in a .ts file.
|
||||
@@ -4,13 +4,13 @@
|
||||
// @Filename: a.js
|
||||
//// var v = <string>undefined;
|
||||
|
||||
verify.getSyntacticDiagnostics(`[
|
||||
verify.getSyntacticDiagnostics(`[]`);
|
||||
verify.getSemanticDiagnostics(`[
|
||||
{
|
||||
"message": "Expected corresponding JSX closing tag for 'string'.",
|
||||
"start": 26,
|
||||
"length": 0,
|
||||
"message": "'type assertion expressions' can only be used in a .ts file.",
|
||||
"start": 9,
|
||||
"length": 6,
|
||||
"category": "error",
|
||||
"code": 17002
|
||||
"code": 8016
|
||||
}
|
||||
]`);
|
||||
verify.getSemanticDiagnostics(`[]`);
|
||||
]`);
|
||||
Reference in New Issue
Block a user