0
브라우저를 통해 비동기 iterator의 typescript (버전 2.6 사용)를 사용하여 빌드 된 예제를 실행하려고합니다. 이름을 찾을 수 없습니다. __values
`
function* countAppleSales() {
var saleList = [3, 7, 5];
for (var i = 0; i < saleList.length; i++) {
yield saleList[i];
}
}
for(let val of countAppleSales())
console.log(val);
async function* asyncRandomNumbers() {
// This is a web service that returns a random number
const url = 'https://www.random.org/decimal-fractions/?num=1&dec=10&col=1&format=plain&rnd=new';
while (true) {
const response = await fetch(url);
const text = await response.text();
yield Number(text);
}
}
async function example() {
for await (const number of asyncRandomNumbers()) {
console.log(number);
if (number > 0.95) break;
}
}
example();
console.log('we are after await')
,`
위의 코드는 브라우저에서 잘 실행되지만 CONSOLE.LOG 로그인 이름 __values을 찾을 수없는 오류가 발생하고있다. 호는 두 번 타이프 라이터 로더 규칙 구성을 붙여 복사 할 예정이다
는{
"compilerOptions": {
"module": "es2015",
"types": [
"node"
],
// typeRoots option has been previously configured
"typeRoots": [
// add path to @types
"node_modules/@types"
],
"target": "es6",
"noImplicitAny": false,
"downlevelIteration": false,
"sourceMap": true,
"moduleResolution": "node",
"watch": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
//"noEmitHelpers": true,
"skipDefaultLibCheck": true,
"strictNullChecks": false,
"outDir": "tmp",
//"lib":["es2017","es2015","es2016","es2015.generator","esnext","dom","esnext.asynciterable"]
"lib": [ "es2017","dom","es2015.generator","es2015","es2015.iterable","esnext.asynciterable","esnext"]
},
"allowSyntheticDefaultImports":true,
"baseUrl": ".",
"paths": {
"lodash/*": [
"node_modules/@types/lodash-es/*"
]},
"awesomeTypescriptLoaderOptions": {
"useBabel": true,
"useCache": true
},
"include": [
"src",
"test"
],
"exclude": [
"node_modules",
"typings"
]
}
사람이
그리고'__values'는 어디서 오는 거죠? 나는 당신의 코드에서 그것을 보지 못한다. 또한, async function asyncRandomNumbers (비동기 생성기) – Tali
과 같은 일을 할 수 없다고 생각합니다. 문제는 지금 해결되었습니다. 문제는 webpack 구성 파일에 typescript 로더 규칙 구성을 두 번 붙여 넣기 때문입니다. webpack 오류가 더 구체적이어야하지만. –