Skip to content

Commit fb9e625

Browse files
matt-gaddCompuIves
authored andcommitted
Use tsconfig setting for jsxFactory and reactNamespace in editor(s) (codesandbox#1490)
* changes editor options (vscode and standard monaco) to use factory or namespace from tsconfig if available * tslint issues
1 parent 7e4a81c commit fb9e625

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/app/src/app/components/CodeEditor/Monaco/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,12 @@ class MonacoEditor extends React.Component<Props, State> implements Editor {
328328
setCompilerOptions = () => {
329329
const hasNativeTypescript = this.hasNativeTypescript();
330330
const existingConfig = this.tsconfig ? this.tsconfig.compilerOptions : {};
331+
const jsxFactory = existingConfig.jsxFactory || 'React.createElement';
332+
const reactNamespace = existingConfig.reactNamespace || 'React';
331333

332334
const compilerDefaults = {
333-
jsxFactory: 'React.createElement',
334-
reactNamespace: 'React',
335+
jsxFactory,
336+
reactNamespace,
335337
jsx: this.monaco.languages.typescript.JsxEmit.React,
336338
target: this.monaco.languages.typescript.ScriptTarget.ES2016,
337339
allowNonTsExtensions: !hasNativeTypescript,

packages/app/src/app/components/CodeEditor/VSCode/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,12 @@ class MonacoEditor extends React.Component<Props, State> implements Editor {
418418
setCompilerOptions = () => {
419419
const hasNativeTypescript = this.hasNativeTypescript();
420420
const existingConfig = this.tsconfig ? this.tsconfig.compilerOptions : {};
421+
const jsxFactory = existingConfig.jsxFactory || 'React.createElement';
422+
const reactNamespace = existingConfig.reactNamespace || 'React';
421423

422424
const compilerDefaults = {
423-
jsxFactory: 'React.createElement',
424-
reactNamespace: 'React',
425+
jsxFactory,
426+
reactNamespace,
425427
jsx: this.monaco.languages.typescript.JsxEmit.React,
426428
target: this.monaco.languages.typescript.ScriptTarget.ES2016,
427429
allowNonTsExtensions: !hasNativeTypescript,

0 commit comments

Comments
 (0)