Skip to content

Commit 67587cb

Browse files
author
Arthur Ozga
committed
Merge branch 'master' into createTypeNode
2 parents 57cd9ea + de52113 commit 67587cb

File tree

78 files changed

+99
-77
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+99
-77
lines changed

Gulpfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo
749749
const originalMap = file.sourceMap;
750750
const prebundledContent = file.contents.toString();
751751
// Make paths absolute to help sorcery deal with all the terrible paths being thrown around
752-
originalMap.sources = originalMap.sources.map(s => path.resolve(s));
752+
originalMap.sources = originalMap.sources.map(s => path.resolve(path.join("src/harness", s)));
753753
// intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap
754754
originalMap.file = "built/local/_stream_0.js";
755755

src/compiler/parser.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3863,6 +3863,9 @@ namespace ts {
38633863
parseErrorAtPosition(openingTagName.pos, openingTagName.end - openingTagName.pos, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTagName));
38643864
break;
38653865
}
3866+
else if (token() === SyntaxKind.ConflictMarkerTrivia) {
3867+
break;
3868+
}
38663869
result.push(parseJsxChild());
38673870
}
38683871

src/compiler/scanner.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,14 @@ namespace ts {
17161716
while (pos < end) {
17171717
pos++;
17181718
char = text.charCodeAt(pos);
1719-
if ((char === CharacterCodes.openBrace) || (char === CharacterCodes.lessThan)) {
1719+
if (char === CharacterCodes.openBrace) {
1720+
break;
1721+
}
1722+
if (char === CharacterCodes.lessThan) {
1723+
if (isConflictMarkerTrivia(text, pos)) {
1724+
pos = scanConflictMarkerTrivia(text, pos, error);
1725+
return token = SyntaxKind.ConflictMarkerTrivia;
1726+
}
17201727
break;
17211728
}
17221729
}

src/compiler/sys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ namespace ts {
202202
if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
203203
// Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js,
204204
// flip all byte pairs and treat as little endian.
205-
len &= ~1;
205+
len &= ~1; // Round down to a multiple of 2
206206
for (let i = 0; i < len; i += 2) {
207207
const temp = buffer[i];
208208
buffer[i] = buffer[i + 1];

src/compiler/transformers/module/module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ namespace ts {
8989
startLexicalEnvironment();
9090

9191
const statements: Statement[] = [];
92-
const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor);
92+
const ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && isExternalModule(currentSourceFile));
93+
const statementOffset = addPrologueDirectives(statements, node.statements, ensureUseStrict, sourceElementVisitor);
9394

9495
if (shouldEmitUnderscoreUnderscoreESModule()) {
9596
append(statements, createUnderscoreUnderscoreESModule());

src/compiler/transformers/module/system.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ namespace ts {
225225
startLexicalEnvironment();
226226

227227
// Add any prologue directives.
228-
const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor);
228+
const ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && isExternalModule(currentSourceFile));
229+
const statementOffset = addPrologueDirectives(statements, node.statements, ensureUseStrict, sourceElementVisitor);
229230

230231
// var __moduleName = context_1 && context_1.id;
231232
statements.push(

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3006,6 +3006,42 @@ namespace ts.projectSystem {
30063006
const errorResult = <protocol.Diagnostic[]>session.executeCommand(dTsFileGetErrRequest).response;
30073007
assert.isTrue(errorResult.length === 0);
30083008
});
3009+
3010+
it("should be turned on for js-only external projects with skipLibCheck=false", () => {
3011+
const jsFile = {
3012+
path: "/a/b/file1.js",
3013+
content: "let x =1;"
3014+
};
3015+
const dTsFile = {
3016+
path: "/a/b/file2.d.ts",
3017+
content: `
3018+
interface T {
3019+
name: string;
3020+
};
3021+
interface T {
3022+
name: number;
3023+
};`
3024+
};
3025+
const host = createServerHost([jsFile, dTsFile]);
3026+
const session = createSession(host);
3027+
3028+
const openExternalProjectRequest = makeSessionRequest<protocol.OpenExternalProjectArgs>(
3029+
CommandNames.OpenExternalProject,
3030+
{
3031+
projectFileName: "project1",
3032+
rootFiles: toExternalFiles([jsFile.path, dTsFile.path]),
3033+
options: { skipLibCheck: false }
3034+
}
3035+
);
3036+
session.executeCommand(openExternalProjectRequest);
3037+
3038+
const dTsFileGetErrRequest = makeSessionRequest<protocol.SemanticDiagnosticsSyncRequestArgs>(
3039+
CommandNames.SemanticDiagnosticsSync,
3040+
{ file: dTsFile.path }
3041+
);
3042+
const errorResult = <protocol.Diagnostic[]>session.executeCommand(dTsFileGetErrRequest).response;
3043+
assert.isTrue(errorResult.length === 0);
3044+
});
30093045
});
30103046

30113047
describe("non-existing directories listed in config file input array", () => {

src/server/session.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,7 @@ namespace ts.server {
2626
}
2727

2828
function shouldSkipSematicCheck(project: Project) {
29-
if (project.getCompilerOptions().skipLibCheck !== undefined) {
30-
return false;
31-
}
32-
33-
if ((project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) && project.isJsOnlyProject()) {
34-
return true;
35-
}
36-
return false;
29+
return (project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) && project.isJsOnlyProject();
3730
}
3831

3932
interface FileStart {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
tests/cases/compiler/conflictMarkerTrivia3.tsx(1,11): error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
2+
tests/cases/compiler/conflictMarkerTrivia3.tsx(1,16): error TS1005: '</' expected.
3+
tests/cases/compiler/conflictMarkerTrivia3.tsx(2,1): error TS1185: Merge conflict marker encountered.
4+
5+
6+
==== tests/cases/compiler/conflictMarkerTrivia3.tsx (3 errors) ====
7+
const x = <div>
8+
~~~~~
9+
!!! error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
10+
11+
<<<<<<< HEAD
12+
~~~~~~~~~~~~
13+
!!! error TS1005: '</' expected.
14+
~~~~~~~
15+
!!! error TS1185: Merge conflict marker encountered.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//// [conflictMarkerTrivia3.tsx]
2+
const x = <div>
3+
<<<<<<< HEAD
4+
5+
//// [conflictMarkerTrivia3.js]
6+
var x = <div></>;

0 commit comments

Comments
 (0)