Best JavaScript code snippet using storybook-root
transpile.ts
Source:transpile.ts
1/// <reference path="..\harness.ts" />23namespace ts {4 describe("Transpile", () => {56 interface TranspileTestSettings {7 options?: TranspileOptions;8 }910 function transpilesCorrectly(name: string, input: string, testSettings: TranspileTestSettings) {11 describe(name, () => {12 let justName: string;13 let transpileOptions: TranspileOptions;14 let canUseOldTranspile: boolean;15 let toBeCompiled: Harness.Compiler.TestFile[];16 let transpileResult: TranspileOutput;17 let oldTranspileResult: string;18 let oldTranspileDiagnostics: Diagnostic[];1920 before(() => {21 transpileOptions = testSettings.options || {};22 if (!transpileOptions.compilerOptions) {23 transpileOptions.compilerOptions = {};24 }2526 if (transpileOptions.compilerOptions.newLine === undefined) {27 // use \r\n as default new line28 transpileOptions.compilerOptions.newLine = ts.NewLineKind.CarriageReturnLineFeed;29 }3031 transpileOptions.compilerOptions.sourceMap = true;3233 if (!transpileOptions.fileName) {34 transpileOptions.fileName = transpileOptions.compilerOptions.jsx ? "file.tsx" : "file.ts";35 }3637 transpileOptions.reportDiagnostics = true;3839 justName = "transpile/" + name.replace(/[^a-z0-9\-. ]/ig, "") + (transpileOptions.compilerOptions.jsx ? ".tsx" : ".ts");40 toBeCompiled = [{41 unitName: transpileOptions.fileName,42 content: input43 }];4445 canUseOldTranspile = !transpileOptions.renamedDependencies;46 transpileResult = transpileModule(input, transpileOptions);4748 if (canUseOldTranspile) {49 oldTranspileDiagnostics = [];50 oldTranspileResult = transpile(input, transpileOptions.compilerOptions, transpileOptions.fileName, oldTranspileDiagnostics, transpileOptions.moduleName);51 }52 });5354 after(() => {55 justName = undefined;56 transpileOptions = undefined;57 canUseOldTranspile = undefined;58 toBeCompiled = undefined;59 transpileResult = undefined;60 oldTranspileResult = undefined;61 oldTranspileDiagnostics = undefined;62 });6364 it("Correct errors for " + justName, () => {65 Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".errors.txt"), () => {66 if (transpileResult.diagnostics.length === 0) {67 /* tslint:disable:no-null-keyword */68 return null;69 /* tslint:enable:no-null-keyword */70 }7172 return Harness.Compiler.getErrorBaseline(toBeCompiled, transpileResult.diagnostics);73 });74 });7576 if (canUseOldTranspile) {77 it("Correct errors (old transpile) for " + justName, () => {78 Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".oldTranspile.errors.txt"), () => {79 if (oldTranspileDiagnostics.length === 0) {80 /* tslint:disable:no-null-keyword */81 return null;82 /* tslint:enable:no-null-keyword */83 }8485 return Harness.Compiler.getErrorBaseline(toBeCompiled, oldTranspileDiagnostics);86 });87 });88 }8990 it("Correct output for " + justName, () => {91 Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".js"), () => {92 if (transpileResult.outputText) {93 return transpileResult.outputText;94 }95 else {96 // This can happen if compiler recieve invalid compiler-options97 /* tslint:disable:no-null-keyword */98 return null;99 /* tslint:enable:no-null-keyword */100 }101 });102 });103104 if (canUseOldTranspile) {105 it("Correct output (old transpile) for " + justName, () => {106 Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".oldTranspile.js"), () => {107 return oldTranspileResult;108 });109 });110 }111 });112 }113114 transpilesCorrectly("Generates no diagnostics with valid inputs", `var x = 0;`, {115 options: { compilerOptions: { module: ModuleKind.CommonJS } }116 });117118 transpilesCorrectly("Generates no diagnostics for missing file references", `/// <reference path="file2.ts" />119var x = 0;`, {120 options: { compilerOptions: { module: ModuleKind.CommonJS } }121 });122123 transpilesCorrectly("Generates no diagnostics for missing module imports", `import {a} from "module2";`, {124 options: { compilerOptions: { module: ModuleKind.CommonJS } }125 });126127 transpilesCorrectly("Generates expected syntactic diagnostics", `a b`, {128 options: { compilerOptions: { module: ModuleKind.CommonJS } }129 });130131 transpilesCorrectly("Does not generate semantic diagnostics", `var x: string = 0;`, {132 options: { compilerOptions: { module: ModuleKind.CommonJS } }133 });134135 transpilesCorrectly("Generates module output", `var x = 0;`, {136 options: { compilerOptions: { module: ModuleKind.AMD } }137 });138139 transpilesCorrectly("Uses correct newLine character", `var x = 0;`, {140 options: { compilerOptions: { module: ModuleKind.CommonJS, newLine: NewLineKind.LineFeed } }141 });142143 transpilesCorrectly("Sets module name", "var x = 1;", {144 options: { compilerOptions: { module: ModuleKind.System, newLine: NewLineKind.LineFeed }, moduleName: "NamedModule" }145 });146147 transpilesCorrectly("No extra errors for file without extension", `"use strict";\r\nvar x = 0;`, {148 options: { compilerOptions: { module: ModuleKind.CommonJS }, fileName: "file" }149 });150151 transpilesCorrectly("Rename dependencies - System",152 `import {foo} from "SomeName";\n` +153 `declare function use(a: any);\n` +154 `use(foo);`, {155 options: { compilerOptions: { module: ModuleKind.System, newLine: NewLineKind.LineFeed }, renamedDependencies: { "SomeName": "SomeOtherName" } }156 });157158 transpilesCorrectly("Rename dependencies - AMD",159 `import {foo} from "SomeName";\n` +160 `declare function use(a: any);\n` +161 `use(foo);`, {162 options: { compilerOptions: { module: ModuleKind.AMD, newLine: NewLineKind.LineFeed }, renamedDependencies: { "SomeName": "SomeOtherName" } }163 });164165 transpilesCorrectly("Rename dependencies - UMD",166 `import {foo} from "SomeName";\n` +167 `declare function use(a: any);\n` +168 `use(foo);`, {169 options: { compilerOptions: { module: ModuleKind.UMD, newLine: NewLineKind.LineFeed }, renamedDependencies: { "SomeName": "SomeOtherName" } }170 });171172 transpilesCorrectly("Transpile with emit decorators and emit metadata",173 `import {db} from './db';\n` +174 `function someDecorator(target) {\n` +175 ` return target;\n` +176 `} \n` +177 `@someDecorator\n` +178 `class MyClass {\n` +179 ` db: db;\n` +180 ` constructor(db: db) {\n` +181 ` this.db = db;\n` +182 ` this.db.doSomething(); \n` +183 ` }\n` +184 `}\n` +185 `export {MyClass}; \n`, {186 options: {187 compilerOptions: {188 module: ModuleKind.CommonJS,189 newLine: NewLineKind.LineFeed,190 noEmitHelpers: true,191 emitDecoratorMetadata: true,192 experimentalDecorators: true,193 target: ScriptTarget.ES5,194 }195 }196 });197198 transpilesCorrectly("Supports backslashes in file name", "var x", {199 options: { fileName: "a\\b.ts" }200 });201202 transpilesCorrectly("transpile file as 'tsx' if 'jsx' is specified", `var x = <div/>`, {203 options: { compilerOptions: { jsx: JsxEmit.React, newLine: NewLineKind.LineFeed } }204 });205206 transpilesCorrectly("transpile .js files", "const a = 10;", {207 options: { compilerOptions: { newLine: NewLineKind.LineFeed, module: ModuleKind.CommonJS }, fileName: "input.js", reportDiagnostics: true }208 });209210 transpilesCorrectly("Supports urls in file name", "var x", {211 options: { fileName: "http://somewhere/directory//directory2/file.ts" }212 });213214 transpilesCorrectly("Accepts string as enum values for compile-options", "export const x = 0", {215 options: {216 compilerOptions: {217 module: <ModuleKind><any>"es6",218 // Capitalization and spaces ignored219 target: <ScriptTarget><any>" Es6 "220 }221 }222 });223224 transpilesCorrectly("Report an error when compiler-options module-kind is out-of-range", "", {225 options: { compilerOptions: { module: <ModuleKind><any>123 } }226 });227228 transpilesCorrectly("Report an error when compiler-options target-script is out-of-range", "", {229 options: { compilerOptions: { module: <ModuleKind><any>123 } }230 });231232 transpilesCorrectly("Support options with lib values", "const a = 10;", {233 options: { compilerOptions: { lib: ["es6", "dom"], module: ModuleKind.CommonJS }, fileName: "input.js", reportDiagnostics: true }234 });235236 transpilesCorrectly("Support options with types values", "const a = 10;", {237 options: { compilerOptions: { types: ["jquery", "typescript"], module: ModuleKind.CommonJS }, fileName: "input.js", reportDiagnostics: true }238 });239240 transpilesCorrectly("Supports setting 'allowJs'", "x;", {241 options: { compilerOptions: { allowJs: true }, fileName: "input.js", reportDiagnostics: true }242 });243244 transpilesCorrectly("Supports setting 'allowSyntheticDefaultImports'", "x;", {245 options: { compilerOptions: { allowSyntheticDefaultImports: true }, fileName: "input.js", reportDiagnostics: true }246 });247248 transpilesCorrectly("Supports setting 'allowUnreachableCode'", "x;", {249 options: { compilerOptions: { allowUnreachableCode: true }, fileName: "input.js", reportDiagnostics: true }250 });251252 transpilesCorrectly("Supports setting 'allowUnusedLabels'", "x;", {253 options: { compilerOptions: { allowUnusedLabels: true }, fileName: "input.js", reportDiagnostics: true }254 });255256 transpilesCorrectly("Supports setting 'baseUrl'", "x;", {257 options: { compilerOptions: { baseUrl: "./folder/baseUrl" }, fileName: "input.js", reportDiagnostics: true }258 });259260 transpilesCorrectly("Supports setting 'charset'", "x;", {261 options: { compilerOptions: { charset: "en-us" }, fileName: "input.js", reportDiagnostics: true }262 });263264 transpilesCorrectly("Supports setting 'declaration'", "x;", {265 options: { compilerOptions: { declaration: true }, fileName: "input.js", reportDiagnostics: true }266 });267268 transpilesCorrectly("Supports setting 'declarationDir'", "x;", {269 options: { compilerOptions: { declarationDir: "out/declarations" }, fileName: "input.js", reportDiagnostics: true }270 });271272 transpilesCorrectly("Supports setting 'emitBOM'", "x;", {273 options: { compilerOptions: { emitBOM: true }, fileName: "input.js", reportDiagnostics: true }274 });275276 transpilesCorrectly("Supports setting 'emitDecoratorMetadata'", "x;", {277 options: { compilerOptions: { emitDecoratorMetadata: true, experimentalDecorators: true }, fileName: "input.js", reportDiagnostics: true }278 });279280 transpilesCorrectly("Supports setting 'experimentalDecorators'", "x;", {281 options: { compilerOptions: { experimentalDecorators: true }, fileName: "input.js", reportDiagnostics: true }282 });283284 transpilesCorrectly("Supports setting 'forceConsistentCasingInFileNames'", "x;", {285 options: { compilerOptions: { forceConsistentCasingInFileNames: true }, fileName: "input.js", reportDiagnostics: true }286 });287288 transpilesCorrectly("Supports setting 'isolatedModules'", "x;", {289 options: { compilerOptions: { isolatedModules: true }, fileName: "input.js", reportDiagnostics: true }290 });291292 transpilesCorrectly("Supports setting 'jsx'", "x;", {293 options: { compilerOptions: { jsx: 1 }, fileName: "input.js", reportDiagnostics: true }294 });295296 transpilesCorrectly("Supports setting 'lib'", "x;", {297 options: { compilerOptions: { lib: ["es2015", "dom"] }, fileName: "input.js", reportDiagnostics: true }298 });299300 transpilesCorrectly("Supports setting 'locale'", "x;", {301 options: { compilerOptions: { locale: "en-us" }, fileName: "input.js", reportDiagnostics: true }302 });303304 transpilesCorrectly("Supports setting 'module'", "x;", {305 options: { compilerOptions: { module: ModuleKind.CommonJS }, fileName: "input.js", reportDiagnostics: true }306 });307308 transpilesCorrectly("Supports setting 'moduleResolution'", "x;", {309 options: { compilerOptions: { moduleResolution: ModuleResolutionKind.NodeJs }, fileName: "input.js", reportDiagnostics: true }310 });311312 transpilesCorrectly("Supports setting 'newLine'", "x;", {313 options: { compilerOptions: { newLine: NewLineKind.CarriageReturnLineFeed }, fileName: "input.js", reportDiagnostics: true }314 });315316 transpilesCorrectly("Supports setting 'noEmit'", "x;", {317 options: { compilerOptions: { noEmit: true }, fileName: "input.js", reportDiagnostics: true }318 });319320 transpilesCorrectly("Supports setting 'noEmitHelpers'", "x;", {321 options: { compilerOptions: { noEmitHelpers: true }, fileName: "input.js", reportDiagnostics: true }322 });323324 transpilesCorrectly("Supports setting 'noEmitOnError'", "x;", {325 options: { compilerOptions: { noEmitOnError: true }, fileName: "input.js", reportDiagnostics: true }326 });327328 transpilesCorrectly("Supports setting 'noErrorTruncation'", "x;", {329 options: { compilerOptions: { noErrorTruncation: true }, fileName: "input.js", reportDiagnostics: true }330 });331332 transpilesCorrectly("Supports setting 'noFallthroughCasesInSwitch'", "x;", {333 options: { compilerOptions: { noFallthroughCasesInSwitch: true }, fileName: "input.js", reportDiagnostics: true }334 });335336 transpilesCorrectly("Supports setting 'noImplicitAny'", "x;", {337 options: { compilerOptions: { noImplicitAny: true }, fileName: "input.js", reportDiagnostics: true }338 });339340 transpilesCorrectly("Supports setting 'noImplicitReturns'", "x;", {341 options: { compilerOptions: { noImplicitReturns: true }, fileName: "input.js", reportDiagnostics: true }342 });343344 transpilesCorrectly("Supports setting 'noImplicitThis'", "x;", {345 options: { compilerOptions: { noImplicitThis: true }, fileName: "input.js", reportDiagnostics: true }346 });347348 transpilesCorrectly("Supports setting 'noImplicitUseStrict'", "x;", {349 options: { compilerOptions: { noImplicitUseStrict: true }, fileName: "input.js", reportDiagnostics: true }350 });351352 transpilesCorrectly("Supports setting 'noLib'", "x;", {353 options: { compilerOptions: { noLib: true }, fileName: "input.js", reportDiagnostics: true }354 });355356 transpilesCorrectly("Supports setting 'noResolve'", "x;", {357 options: { compilerOptions: { noResolve: true }, fileName: "input.js", reportDiagnostics: true }358 });359360 transpilesCorrectly("Supports setting 'out'", "x;", {361 options: { compilerOptions: { out: "./out" }, fileName: "input.js", reportDiagnostics: true }362 });363364 transpilesCorrectly("Supports setting 'outDir'", "x;", {365 options: { compilerOptions: { outDir: "./outDir" }, fileName: "input.js", reportDiagnostics: true }366 });367368 transpilesCorrectly("Supports setting 'outFile'", "x;", {369 options: { compilerOptions: { outFile: "./outFile" }, fileName: "input.js", reportDiagnostics: true }370 });371372 transpilesCorrectly("Supports setting 'paths'", "x;", {373 options: { compilerOptions: { paths: { "*": ["./generated*"] } }, fileName: "input.js", reportDiagnostics: true }374 });375376 transpilesCorrectly("Supports setting 'preserveConstEnums'", "x;", {377 options: { compilerOptions: { preserveConstEnums: true }, fileName: "input.js", reportDiagnostics: true }378 });379380 transpilesCorrectly("Supports setting 'reactNamespace'", "x;", {381 options: { compilerOptions: { reactNamespace: "react" }, fileName: "input.js", reportDiagnostics: true }382 });383384 transpilesCorrectly("Supports setting 'removeComments'", "x;", {385 options: { compilerOptions: { removeComments: true }, fileName: "input.js", reportDiagnostics: true }386 });387388 transpilesCorrectly("Supports setting 'rootDir'", "x;", {389 options: { compilerOptions: { rootDir: "./rootDir" }, fileName: "input.js", reportDiagnostics: true }390 });391392 transpilesCorrectly("Supports setting 'rootDirs'", "x;", {393 options: { compilerOptions: { rootDirs: ["./a", "./b"] }, fileName: "input.js", reportDiagnostics: true }394 });395396 transpilesCorrectly("Supports setting 'skipLibCheck'", "x;", {397 options: { compilerOptions: { skipLibCheck: true }, fileName: "input.js", reportDiagnostics: true }398 });399400 transpilesCorrectly("Supports setting 'skipDefaultLibCheck'", "x;", {401 options: { compilerOptions: { skipDefaultLibCheck: true }, fileName: "input.js", reportDiagnostics: true }402 });403404 transpilesCorrectly("Supports setting 'strictNullChecks'", "x;", {405 options: { compilerOptions: { strictNullChecks: true }, fileName: "input.js", reportDiagnostics: true }406 });407408 transpilesCorrectly("Supports setting 'stripInternal'", "x;", {409 options: { compilerOptions: { stripInternal: true }, fileName: "input.js", reportDiagnostics: true }410 });411412 transpilesCorrectly("Supports setting 'suppressExcessPropertyErrors'", "x;", {413 options: { compilerOptions: { suppressExcessPropertyErrors: true }, fileName: "input.js", reportDiagnostics: true }414 });415416 transpilesCorrectly("Supports setting 'suppressImplicitAnyIndexErrors'", "x;", {417 options: { compilerOptions: { suppressImplicitAnyIndexErrors: true }, fileName: "input.js", reportDiagnostics: true }418 });419420 transpilesCorrectly("Supports setting 'target'", "x;", {421 options: { compilerOptions: { target: 2 }, fileName: "input.js", reportDiagnostics: true }422 });423424 transpilesCorrectly("Supports setting 'types'", "x;", {425 options: { compilerOptions: { types: ["jquery", "jasmine"] }, fileName: "input.js", reportDiagnostics: true }426 });427428 transpilesCorrectly("Supports setting 'typeRoots'", "x;", {429 options: { compilerOptions: { typeRoots: ["./folder"] }, fileName: "input.js", reportDiagnostics: true }430 });431432 transpilesCorrectly("Correctly serialize metadata when transpile with CommonJS option",433 `import * as ng from "angular2/core";` +434 `declare function foo(...args: any[]);` +435 `@foo` +436 `export class MyClass1 {` +437 ` constructor(private _elementRef: ng.ElementRef){}` +438 `}`, {439 options: {440 compilerOptions: {441 target: ScriptTarget.ES5,442 module: ModuleKind.CommonJS,443 moduleResolution: ModuleResolutionKind.NodeJs,444 emitDecoratorMetadata: true,445 experimentalDecorators: true,446 isolatedModules: true,447 }448 }449 });450451 transpilesCorrectly("Correctly serialize metadata when transpile with System option",452 `import * as ng from "angular2/core";` +453 `declare function foo(...args: any[]);` +454 `@foo` +455 `export class MyClass1 {` +456 ` constructor(private _elementRef: ng.ElementRef){}` +457 `}`, {458 options: {459 compilerOptions: {460 target: ScriptTarget.ES5,461 module: ModuleKind.System,462 moduleResolution: ModuleResolutionKind.NodeJs,463 emitDecoratorMetadata: true,464 experimentalDecorators: true,465 isolatedModules: true,466 }467 }468 });469 });
...
options.ts
Source:options.ts
1import { h, reactive, createApp, ref } from 'vue'2import { CompilerOptions } from '@vue/compiler-dom'3import { BindingTypes } from '@vue/compiler-core'4export const ssrMode = ref(false)5export const compilerOptions: CompilerOptions = reactive({6 mode: 'module',7 filename: 'Foo.vue',8 prefixIdentifiers: false,9 hoistStatic: false,10 cacheHandlers: false,11 scopeId: null,12 inline: false,13 ssrCssVars: `{ color }`,14 compatConfig: { MODE: 3 },15 whitespace: 'condense',16 bindingMetadata: {17 TestComponent: BindingTypes.SETUP_CONST,18 setupRef: BindingTypes.SETUP_REF,19 setupConst: BindingTypes.SETUP_CONST,20 setupLet: BindingTypes.SETUP_LET,21 setupMaybeRef: BindingTypes.SETUP_MAYBE_REF,22 setupProp: BindingTypes.PROPS,23 vMySetupDir: BindingTypes.SETUP_CONST24 }25})26const App = {27 setup() {28 return () => {29 const isSSR = ssrMode.value30 const isModule = compilerOptions.mode === 'module'31 const usePrefix =32 compilerOptions.prefixIdentifiers || compilerOptions.mode === 'module'33 return [34 h('h1', `Vue 3 Template Explorer`),35 h(36 'a',37 {38 href: `https://github.com/vuejs/vue-next/tree/${__COMMIT__}`,39 target: `_blank`40 },41 `@${__COMMIT__}`42 ),43 ' | ',44 h(45 'a',46 {47 href:48 'https://app.netlify.com/sites/vue-next-template-explorer/deploys',49 target: `_blank`50 },51 'History'52 ),53 h('div', { id: 'options-wrapper' }, [54 h('div', { id: 'options-label' }, 'Options â'),55 h('ul', { id: 'options' }, [56 // mode selection57 h('li', { id: 'mode' }, [58 h('span', { class: 'label' }, 'Mode: '),59 h('input', {60 type: 'radio',61 id: 'mode-module',62 name: 'mode',63 checked: isModule,64 onChange() {65 compilerOptions.mode = 'module'66 }67 }),68 h('label', { for: 'mode-module' }, 'module'),69 ' ',70 h('input', {71 type: 'radio',72 id: 'mode-function',73 name: 'mode',74 checked: !isModule,75 onChange() {76 compilerOptions.mode = 'function'77 }78 }),79 h('label', { for: 'mode-function' }, 'function')80 ]),81 // whitespace handling82 h('li', { id: 'whitespace' }, [83 h('span', { class: 'label' }, 'whitespace: '),84 h('input', {85 type: 'radio',86 id: 'whitespace-condense',87 name: 'whitespace',88 checked: compilerOptions.whitespace === 'condense',89 onChange() {90 compilerOptions.whitespace = 'condense'91 }92 }),93 h('label', { for: 'whitespace-condense' }, 'condense'),94 ' ',95 h('input', {96 type: 'radio',97 id: 'whitespace-preserve',98 name: 'whitespace',99 checked: compilerOptions.whitespace === 'preserve',100 onChange() {101 compilerOptions.whitespace = 'preserve'102 }103 }),104 h('label', { for: 'whitespace-preserve' }, 'preserve')105 ]),106 // SSR107 h('li', [108 h('input', {109 type: 'checkbox',110 id: 'ssr',111 name: 'ssr',112 checked: ssrMode.value,113 onChange(e: Event) {114 ssrMode.value = (e.target as HTMLInputElement).checked115 }116 }),117 h('label', { for: 'ssr' }, 'SSR')118 ]),119 // toggle prefixIdentifiers120 h('li', [121 h('input', {122 type: 'checkbox',123 id: 'prefix',124 disabled: isModule || isSSR,125 checked: usePrefix || isSSR,126 onChange(e: Event) {127 compilerOptions.prefixIdentifiers =128 (e.target as HTMLInputElement).checked || isModule129 }130 }),131 h('label', { for: 'prefix' }, 'prefixIdentifiers')132 ]),133 // toggle hoistStatic134 h('li', [135 h('input', {136 type: 'checkbox',137 id: 'hoist',138 checked: compilerOptions.hoistStatic && !isSSR,139 disabled: isSSR,140 onChange(e: Event) {141 compilerOptions.hoistStatic = (e.target as HTMLInputElement).checked142 }143 }),144 h('label', { for: 'hoist' }, 'hoistStatic')145 ]),146 // toggle cacheHandlers147 h('li', [148 h('input', {149 type: 'checkbox',150 id: 'cache',151 checked: usePrefix && compilerOptions.cacheHandlers && !isSSR,152 disabled: !usePrefix || isSSR,153 onChange(e: Event) {154 compilerOptions.cacheHandlers = (e.target as HTMLInputElement).checked155 }156 }),157 h('label', { for: 'cache' }, 'cacheHandlers')158 ]),159 // toggle scopeId160 h('li', [161 h('input', {162 type: 'checkbox',163 id: 'scope-id',164 disabled: !isModule,165 checked: isModule && compilerOptions.scopeId,166 onChange(e: Event) {167 compilerOptions.scopeId =168 isModule && (e.target as HTMLInputElement).checked169 ? 'scope-id'170 : null171 }172 }),173 h('label', { for: 'scope-id' }, 'scopeId')174 ]),175 // inline mode176 h('li', [177 h('input', {178 type: 'checkbox',179 id: 'inline',180 checked: compilerOptions.inline,181 onChange(e: Event) {182 compilerOptions.inline = (e.target as HTMLInputElement).checked183 }184 }),185 h('label', { for: 'inline' }, 'inline')186 ]),187 // compat mode188 h('li', [189 h('input', {190 type: 'checkbox',191 id: 'compat',192 checked: compilerOptions.compatConfig!.MODE === 2,193 onChange(e: Event) {194 compilerOptions.compatConfig!.MODE = (e.target as HTMLInputElement)195 .checked196 ? 2197 : 3198 }199 }),200 h('label', { for: 'compat' }, 'v2 compat mode')201 ])202 ])203 ])204 ]205 }206 }207}208export function initOptions() {209 createApp(App).mount(document.getElementById('header')!)...
Using AI Code Generation
1const { compilerOptions } = require('../tsconfig.json');2const { pathsToModuleNameMapper } = require('ts-jest/utils');3const { compilerOptions: tsCompilerOptions } = require('../tsconfig.json');4module.exports = {5 moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {6 }),7 transform: {8 },9 globals: {10 'ts-jest': {11 },12 },13 testMatch: ['**/__tests__/**/*.test.(ts|tsx|js)'],14 collectCoverageFrom: ['src/**/*.{ts,tsx,js,jsx}', '!src/**/*.stories.{ts,tsx,js,jsx}'],15};16{17 "compilerOptions": {18 "paths": {
Using AI Code Generation
1const { compilerOptions } = require('@storybook/react/dist/server/config/utils');2module.exports = (baseConfig, env, defaultConfig) => {3 const config = defaultConfig;4 config.module.rules.push({5 {6 },7 {8 options: {9 importLoaders: 2,10 },11 },12 {13 options: {14 plugins: () => [15 require('postcss-cssnext'),16 require('postcss-nested'),17 },18 },19 {20 },21 });22 config.module.rules.push({23 {24 options: {25 },26 },27 });28 config.module.rules.push({29 test: /\.(png|woff|woff2|eot|ttf|svg)$/,30 {31 options: {32 },33 },34 });35 config.resolve.alias = {36 };37 ];38 return config;39};40import { configure } from '@storybook/react';41const req = require.context('../src', true, /.stories.js$/);42function loadStories() {43 req.keys().forEach(filename => req(filename));44}45configure(loadStories, module);46import '@storybook/addon-actions/register';47import '@storybook/addon-links/register';48import '@storybook/addon-knobs/register';
Using AI Code Generation
1const compilerOptions = require('@storybook/react').compilerOptions;2const compilerOptions = require('@storybook/react').compilerOptions;3const compilerOptions = require('@storybook/react').compilerOptions;4const compilerOptions = require('@storybook/react').compilerOptions;5const compilerOptions = require('@storybook/react').compilerOptions;6const compilerOptions = require('@storybook/react').compilerOptions;7const compilerOptions = require('@storybook/react').compilerOptions;8const compilerOptions = require('@storybook/react').compilerOptions;9const compilerOptions = require('@storybook/react').compilerOptions;10const compilerOptions = require('@storybook/react').compilerOptions;11const compilerOptions = require('@storybook/react').compilerOptions;12const compilerOptions = require('@storybook/react').compilerOptions;13const compilerOptions = require('@storybook/react').compilerOptions;14const compilerOptions = require('@storybook/react').compilerOptions;15const compilerOptions = require('@storybook/react').compilerOptions;16const compilerOptions = require('@storybook/react').compilerOptions;17const compilerOptions = require('@storybook/react').compilerOptions;18const compilerOptions = require('@storybook/react').compilerOptions;19const compilerOptions = require('@storybook/react').compilerOptions;
Using AI Code Generation
1const path = require('path');2module.exports = {3 webpackFinal: async (config, { configType }) => {4 ...(config.resolve.modules || []),5 path.resolve(__dirname, '../src'),6 ];7 return config;8 },9};10const path = require('path');11module.exports = {12 webpackFinal: async (config, { configType }) => {13 ...(config.resolve.modules || []),14 path.resolve(__dirname, '../src'),15 ];16 return config;17 },18};19const path = require('path');20module.exports = async ({ config, mode }) => {21 ...(config.resolve.modules || []),22 path.resolve(__dirname, '../src'),23 ];24 return config;25};26const path = require('path');27module.exports = async ({ config, mode }) => {28 ...(config.resolve.modules || []),29 path.resolve(__dirname, '../src'),30 ];31 return config;32};33const path = require('path');34module.exports = async ({ config, mode }) => {35 ...(config.resolve.modules || []),36 path.resolve(__dirname, '../src'),37 ];38 return config;39};40const path = require('path');41module.exports = async ({ config, mode }) => {42 ...(config.resolve.modules || []),43 path.resolve(__dirname, '../
Using AI Code Generation
1module.exports = {2};3const path = require('path');4const compilerOptions = {5 paths: {6 },7};8module.exports = {9};10const path = require('path');11module.exports = {
Using AI Code Generation
1const compilerOptions = require('@storybook/react/dist/server/config/defaults/webpack.config.js').webpackFinal;2module.exports = async (baseConfig, env) => {3const config = await compilerOptions(baseConfig, env);4config.module.rules.push({5include: path.resolve(__dirname, '../'),6});7return config;8};
Using AI Code Generation
1const { compilerOptions } = require('@storybook/react/dist/server/config/defaults/webpack.config.js');2module.exports = {3 webpackFinal: async (config, { configType }) => {4 config.resolve = compilerOptions(config.resolve);5 }6}
Using AI Code Generation
1const path = require("path");2const root = require("app-root-path").path;3const { compilerOptions } = require(path.join(root, "tsconfig.json"));4module.exports = {5 stories: ["../src/**/*.stories.@(js|jsx|ts|tsx)"],6 webpackFinal: async (config) => {7 config.module.rules.push({8 test: /\.(ts|tsx)$/,9 {10 loader: require.resolve("ts-loader"),11 options: {12 },13 },14 {15 loader: require.resolve("react-docgen-typescript-loader"),16 options: {17 },18 },19 });20 config.resolve.extensions.push(".ts", ".tsx");21 return config;22 },23};24module.exports = {25 module: {26 {27 test: /\.(ts|tsx)$/,28 {29 loader: require.resolve("ts-loader"),30 options: {31 },32 },33 {34 loader: require.resolve("react-docgen-typescript-loader"),35 options: {36 },37 },38 },39 },40 resolve: {41 },42};43import { Story, Meta } from "@storybook/react/types-6-0";44import Button, {
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!